<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var Type = {};
    Object.prototype.toString=function(){
        //很明显这里面的this 代表的是这个字符串，这个字符串的原型是String 
        //使用call 方法 改变了this的这个指向 
        return '[object '+this.getType()+']';
    }
    String.prototype.getType=function(){
        return 'String'
    }
    //type = ['String', 'Array', 'Number']
    for (var i = 0, type; type = ['String'][i++];) {
        (function (type) {
            Type['is' + type] = function (obj) {
                console.log(Object.prototype.toString.call(obj));
                return Object.prototype.toString.call(obj) === '[object ' + type + ']';
                //这是根据Object的方法，
            }
        })(type)
    };
   // console.log(Type.isArray([]))

    console.log(Type.isString("str"))

</script>

</html>